package com.ruoyi.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SafetyExaminationStudentWrongRecord;
import com.ruoyi.system.service.ISafetyExaminationStudentWrongRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生错题记录Controller
 * 
 * @author ruoyi
 * @date 2021-04-07
 */
@RestController
@RequestMapping("/system/examinationstudentwrongrecord")
public class SafetyExaminationStudentWrongRecordController extends BaseController
{
    @Autowired
    private ISafetyExaminationStudentWrongRecordService safetyExaminationStudentWrongRecordService;

    /**
     * 查询学生错题记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:examinationstudentwrongrecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(SafetyExaminationStudentWrongRecord safetyExaminationStudentWrongRecord)
    {
        startPage();
        List<SafetyExaminationStudentWrongRecord> list = safetyExaminationStudentWrongRecordService.selectSafetyExaminationStudentWrongRecordList(safetyExaminationStudentWrongRecord);
        return getDataTable(list);
    }

    /**
     * 导出学生错题记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:examinationstudentwrongrecord:export')")
    @Log(title = "学生错题记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SafetyExaminationStudentWrongRecord safetyExaminationStudentWrongRecord)
    {
        List<SafetyExaminationStudentWrongRecord> list = safetyExaminationStudentWrongRecordService.selectSafetyExaminationStudentWrongRecordList(safetyExaminationStudentWrongRecord);
        ExcelUtil<SafetyExaminationStudentWrongRecord> util = new ExcelUtil<SafetyExaminationStudentWrongRecord>(SafetyExaminationStudentWrongRecord.class);
        return util.exportExcel(list, "examinationstudentwrongrecord");
    }

    /**
     * 获取学生错题记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:examinationstudentwrongrecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(safetyExaminationStudentWrongRecordService.selectSafetyExaminationStudentWrongRecordById(id));
    }

    /**
     * 新增学生错题记录
     */
    @PreAuthorize("@ss.hasPermi('system:examinationstudentwrongrecord:add')")
    @Log(title = "学生错题记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SafetyExaminationStudentWrongRecord safetyExaminationStudentWrongRecord)
    {
        return toAjax(safetyExaminationStudentWrongRecordService.insertSafetyExaminationStudentWrongRecord(safetyExaminationStudentWrongRecord));
    }

    /**
     * 修改学生错题记录
     */
    @PreAuthorize("@ss.hasPermi('system:examinationstudentwrongrecord:edit')")
    @Log(title = "学生错题记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SafetyExaminationStudentWrongRecord safetyExaminationStudentWrongRecord)
    {
        return toAjax(safetyExaminationStudentWrongRecordService.updateSafetyExaminationStudentWrongRecord(safetyExaminationStudentWrongRecord));
    }

    /**
     * 删除学生错题记录
     */
    @PreAuthorize("@ss.hasPermi('system:examinationstudentwrongrecord:remove')")
    @Log(title = "学生错题记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(safetyExaminationStudentWrongRecordService.deleteSafetyExaminationStudentWrongRecordByIds(ids));
    }
}
